﻿using Common.Helper;
using Sunny.UI;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1.控件
{
    public partial class SqlFormBaseToolContorl : UIUserControl
    {
        private Type sqlTableType;

        public Type SqlTbleType
        {
            get { return sqlTableType; }
            set
            {
                if (sqlTableType != null) { throw new Exception("重复赋值"); }
                sqlTableType = value;
                ContorlGenerateHelper.SetGridPropertyAndName(uiDataGridView1, sqlTableType);
            }
        }

        private List<UILabel> titles = new List<UILabel>();
        private List<UIControl> controls = new List<UIControl>();
        public SqlFormBaseToolContorl()
        {
            InitializeComponent();
        }

        private void GetContorlName(Type type)
        {
            var map = ReflectHelper.GetSqlEntityDesctionAndType(type);
            int i = 0;
            foreach (var item in map)
            {
                var label = new UILabel();
                UIPanel contorl;
                label.Text = item.Key;
                if (item.Value == typeof(DateTime))
                {
                    contorl = new UIDatetimePicker();
                }
                else if (item.Value == typeof(string))
                {
                    contorl = new UITextBox();
                }
            }

        }
    }
}
